#! gmake

#
# Copyright (C) 2014 François Beaulier
# 
# This file is part of canfestival, a library implementing the canopen
# stack
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 

CC = SUB_CC
PROG_CFLAGS = SUB_PROG_CFLAGS

LIB_ROOT = ../../include/cm0/stlib

INCLUDES = -I../../include \
		   -I../../include/cm0 \
           -I$(LIB_ROOT)/STM32F0xx_StdPeriph_Driver/inc \
           -I$(LIB_ROOT)/CMSIS/Device/ST/STM32F0xx/Include/ \
           -I$(LIB_ROOT)/CMSIS/Include \
		   -I.

DEFINES = -DSTM32F072 -DUSE_STDPERIPH_DRIVER

CFLAGS = $(PROG_CFLAGS) $(DEFINES)

OBJS = cm0.o 

all: driver

driver: $(OBJS)

libcandriver.a: $(OBJS)
	@echo " "
	@echo "*********************************************"
	@echo "**Building libcandriver for arm cortex-M0
	@echo "*********************************************"
	ar rc $@ $(OBJS)
	ranlib $@

%.o: %.c
	@echo " "
	@echo "*********************************************"
	@echo "**Compiling $< -> $@"
	@echo "*********************************************"
	$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<

clean:
	rm -f $(OBJS)

mrproper: clean

